package com.idconfirmsystem.handler;

import com.idconfirmsystem.Constants;
import com.idconfirmsystem.R;
import com.idconfirmsystem.activity.LoginControlActivity;
import com.idconfirmsystem.activity.MainActivity;
import com.idconfirmsystem.model.UserBean;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;

public class LoginHandler extends Handler {
	private static final String TAG = "LoginControlActivity";

	private LoginControlActivity context;

	public LoginHandler(LoginControlActivity context) {
		this.context = context;
	}

	public void handleMessage(Message msg) {
		switch (msg.what) {
		// case Constants.MsgWhat.GO_MAP_ACTIVITY:
		// context.startActivity(new Intent(context, MapActivity.class));
		// context.finish();
		// break;
		case Constants.MsgWhat.GO_MENU_CONTROL_ACTIVITY:
			context.startActivity(new Intent(context, MainActivity.class));
			context.finish();
			context.dialogDismiss();
			break;
		case Constants.Login.DIALOG_SHOW:
			String message = context.getString(R.string.login_in);
			context.dialogDisplay(message);
			break;
		case Constants.Login.DIALOG_DISMISS:
			context.dialogDismiss();
			break;
		case Constants.Login.LOGIN_FAILE:
			context.showMessage(UserBean.getInstance().getAae317());
			context.dialogDismiss();
			break;
		case Constants.Login.SERVER_FAILE:
			context.showMessage("服务调用出错！");
			context.dialogDismiss();
			break;
		case Constants.Login.LOGIN:
			context.login();
			break;
		default:
			String str = context.getString(R.string.login_in_faile);
			if (str != null)
				// CommonHelper.Msg.showShortText(context, str);
				break;
		}
		super.handleMessage(msg);
	}
}
